<?php

namespace App\Models;

use App\Enums\AvailableStatus;
use BenSampo\Enum\Traits\CastsEnums;

/**
 * @mixin IdeHelperConvertFormula
 */
class ConvertFormula extends BaseModel
{
    use CastsEnums;

    protected $casts = [
        'status' => AvailableStatus::class,
    ];

    public function target()
    {
        return $this->belongsTo(Product::class, 'target_product_id');
    }

    public function demands()
    {
        return $this->hasMany(ConvertDemand::class);
    }

    public function records()
    {
        return $this->hasMany(ConvertRecord::class);
    }

    public function agent()
    {
        return $this->belongsTo(Agent::class);
    }
}
